#include "BattleMap.h"
#include <string>

using std::string;

BattleMap::BattleMap(){
	rows = 10;
	cols = 10;
	map = new int [rows][cols];
	for(int r = 0; r < rows; r++){
		for(int c = 0; c < cols; c++){
			map[r][c] = -1;
		}
	}
}

BattleMap::BattleMap(int Square){
	rows = Square;
	cols = Square;
	map = new int [rows][cols];
	for(int r = 0; r < rows; r++){
		for(int c = 0; c < cols; c++){
			map[r][c] = -1;
		}
	}
}

BattleMap::BattleMap(int r, int c){
	rows = r;
	cols = c;
	map = new int [rows][cols];
	for(r = 0; r < rows; r++){
		for(c = 0; c < cols; c++){
			map[r][c] = -1;
		}
	}
}

int BattleMap::operator[](string Cell){
	if(Cell.size() > 3 || Cell[0] >= ('A'+(char)cols) || Cell[0] < 'A'){
		return -4;
	}else{if((int)Cell.substr(1) > rows || (int)Cell.substr(1) < 1)
		return -4;
	}else{
		return map[(int)Cell.substr(1) - 1][(int)(Cell[0] - 'A')];
	}
}